.TH std::negate 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::negate \- std::negate

.SH Synopsis
   Defined in header <functional>
   template< class T >             \fI(until C++14)\fP
   struct negate;
   template< class T = void >      \fI(since C++14)\fP
   struct negate;

   Function object for performing negation. Effectively calls operator- on an instance
   of type T.

.SH Specializations

   The standard library provides a specialization of std::negate when T
   is not specified, which leaves the parameter types and return type to
   be deduced.
                                                                          \fI(since C++14)\fP
   negate<void> function object implementing -x deducing parameter and
   \fI(C++14)\fP      return types
                \fI(class template specialization)\fP

.SH Member types

   Type                                                  Definition
   result_type (deprecated in C++17)(removed in C++20)   T
   argument_type (deprecated in C++17)(removed in C++20) T

   These member types are obtained via publicly inheriting                \fI(until C++11)\fP
   std::unary_function<T, T>.

.SH Member functions

   operator() returns the negation of the argument
              \fI(public member function)\fP

std::negate::operator()

   T operator()( const T& arg ) const;            \fI(until C++14)\fP
   constexpr T operator()( const T& arg ) const;  \fI(since C++14)\fP

   Returns the negation of arg.

.SH Parameters

   arg - value to compute negation of

.SH Return value

   The result of -arg.

.SH Exceptions

   May throw implementation-defined exceptions.

.SH Possible implementation

   constexpr T operator()(const T& arg) const
   {
       return -arg;
   }
